package com.sentiment.obj;

import org.bson.Document;

/**
 * 专利基本信息
 * @author Ma
 *
 */
public class PatentInfo {

	//专利名
	private String patentTitle;
	//专利类型
	private String patentType;
	//申请（专利）号
	private String patentNum;
	//申请日期
	private String applicationDate;
	//公开（公告）日
	private String disclosureDate;
	//公开（公告）号
	private String disclosureNum;
	//主分类号
	private String classificationMainNum;
	//分类号
	private String classificationNum;
	//申请（专利权）人
	private String applicant;
	//发明（设计）人
	private String inventor;
	//主申请人地址
	private String applicantAdd;
	//专利代理机构（可能没有）
	private String agency;
	//代理人（可能没有）
	private String agent;
	//国别省市代码
	private String cityNum;
	//法律状态
	private String legalStatus;
	//摘要
	private Document Abstract;
	//主权项
	private Document principalClaim;
	//专利状态
	private String patentTypegreen;
	private String id;
	public PatentInfo() {
		this.patentTitle = "0";
		this.patentType = "0";
		this.patentNum = "0";
		this.applicationDate = "0";
		this.disclosureDate = "0";
		this.disclosureNum = "0";
		this.classificationMainNum = "0";
		this.classificationNum = "0";
		this.applicant = "0";
		this.inventor = "0";
		this.applicantAdd = "0";
		this.agency = "null";
		this.agent = "null";
		this.cityNum = "0";
		this.legalStatus = "0";
		this.id = "null";
		this.patentTypegreen = "null";
	}
	public PatentInfo(String patentInfo, String patentAbstract, String principalClaim){
		
		String []info = patentInfo.split("--");
		this.id = "null";
		this.patentTitle = info[0];
		this.patentType = info[1];
		this.patentNum = info[2];
		this.applicationDate = info[3];
		this.disclosureDate = info[4];
		this.disclosureNum = info[5];
		this.classificationMainNum = info[6];
		this.classificationNum = info[7];
		this.applicant = info[8];
		this.inventor = info[9];
		this.applicantAdd = info[10];
		if(info.length == 15){
			this.agency = info[11];
			this.agent = info[12];
			this.cityNum = info[13];
			this.legalStatus = info[14];
		}else if(info.length == 13){
			this.cityNum = info[11];
			this.legalStatus = info[12];
		}
		
		this.Abstract = StringToDocument(patentAbstract);
		this.principalClaim = StringToDocument(principalClaim);
	}
	public PatentInfo(String patentInfo, String patentAbstract, String principalClaim, String patentTypegreen){
//	    super();
		String []info = patentInfo.split("--");
		this.id = "null";
		this.patentTitle = info[1];
		this.patentType = info[2];
		this.legalStatus = info[3];
		this.applicationDate = info[4];
		this.applicant = info[5];
		this.disclosureDate = info[6];
		this.inventor = info[7];
		this.patentNum = info[8];
		this.agency = info[9];
		this.disclosureNum = info[10];
		this.agent = info[11];
		this.classificationMainNum = info[12];
		this.applicantAdd = info[13];
		this.classificationNum = info[14];
		this.cityNum = info[15];
		this.patentTypegreen = patentTypegreen;
		this.Abstract = StringToDocument(patentAbstract);
		this.principalClaim = StringToDocument(principalClaim);
	}
	
	private Document StringToDocument(String s) {
		Document content = new Document();
		s = s.replaceAll("；", "；-").replaceAll("。", "。-").replaceAll("：", "：-");
		String sen[] = s.split("-");
		int charsAmount = 0;
		int i ;
		for(i = 0; i<sen.length ;i++){
			Document stn = new Document();
			stn.append("text", sen[i]);
			charsAmount = charsAmount + sen[i].length();
			stn.append("charsAmount",sen[i].length());
			content.append(Integer.toString(i+1), stn);
		}
		content.append("stnAmount", i);
		content.append("charsAmount", charsAmount);
		return content;
	}
	public void setPatentTypegreen(String patentTypegreen) {
		this.patentTypegreen = patentTypegreen;
	}
	public String getPatentTypegreen() {
		return patentTypegreen;
	}
	public void setPatentTitle(String patentTitle) {
		this.patentTitle = patentTitle;
	}
	public String getPatentTitle() {
		return patentTitle;
	}
	public void setPatentType(String patentType) {
		this.patentType = patentType;
	}
	public String getPatentType() {
		return patentType;
	}
	public void setPatentNum(String patentNum) {
		this.patentNum = patentNum;
	}
	public String getPatentNum() {
		return patentNum;
	}
	public void setApplicationDate(String applicationDate) {
		this.applicationDate = applicationDate;
	}
	public String getApplicationDate() {
		return applicationDate;
	}
	public void setDisclosureDate(String disclosureDate) {
		this.disclosureDate = disclosureDate;
	}
	public String getDisclosureDate() {
		return disclosureDate;
	}
	public void setDisclosureNum(String disclosureNum) {
		this.disclosureNum = disclosureNum;
	}
	public String getDisclosureNum() {
		return disclosureNum;
	}
	public void setClassificationMainNum(String classificationMainNum) {
		this.classificationMainNum = classificationMainNum;
	}
	public String getClassificationMainNum() {
		return classificationMainNum;
	}
	public void setClassificationNum(String classificationNum) {
		this.classificationNum = classificationNum;
	}
	public String getClassificationNum() {
		return classificationNum;
	}
	public void setApplicant(String applicant) {
		this.applicant = applicant;
	}
	public String getApplicant() {
		return applicant;
	}
	public void setInventor(String inventor) {
		this.inventor = inventor;
	}
	public String getInventor() {
		return inventor;
	}
	public void setApplicantAdd(String applicantAdd) {
		this.applicantAdd = applicantAdd;
	}
	public String getApplicantAdd() {
		return applicantAdd;
	}
	public void setAgency(String agency) {
		this.agency = agency;
	}
	public String getAgency() {
		return agency;
	}
	public void setAgent(String agent) {
		this.agent = agent;
	}
	public String getAgent() {
		return agent;
	}
	public void setCityNum(String cityNum) {
		this.cityNum = cityNum;
	}
	public String getCityNum() {
		return cityNum;
	}
	public void setLegalStatus(String legalStatus) {
		this.patentTitle = legalStatus;
	}
	public String getLegalStatus() {
		return legalStatus;
	}
	public void setAbstract(String Abstract) {
		this.Abstract = StringToDocument(Abstract);
	}
	public Document getAbstract() {
		return Abstract;
	}
	public void setPrincipalClaim(String principalClaim) {
		this.principalClaim = StringToDocument(principalClaim);
	}
	public Document getPrincipalClaim() {
		return principalClaim;
	}
	
	/*
	public PatentInfo(String patentTitle,String patentType, String patentNum, String applicationDate,
			  String disclosureDate, String disclosureNum, String classificationMainNum,
			  String classificationNum, String applicant, String inventor,
			  String applicantAdd, String cityNum, String legalStatus){
		super();
		this.id = "null";
		this.patentTitle = patentTitle;
		this.patentType = patentType;
		this.patentNum = patentNum;
		this.applicationDate = applicationDate;
		this.disclosureDate = disclosureDate;
		this.disclosureNum = disclosureNum;
		this.classificationMainNum = classificationMainNum;
		this.classificationNum = classificationNum;
		this.applicant = applicant;
		this.inventor = inventor;
		this.applicantAdd = applicantAdd;
		this.agency = "null";
		this.agent = "null";
		this.cityNum = cityNum;
		this.legalStatus = legalStatus;
		}*/
	@Override
	public String toString() {
		return "PatentInfo [ " + "patentTitle: " + patentTitle
				+ "patentType: " + patentType
				+"patentNum: " + patentNum
				+"applicationDate: " + applicationDate
				+"disclosureDate: " + disclosureDate
				+"disclosureNum: " + disclosureNum
				+"classificationMainNum: " + classificationMainNum
				+"classificationNum: " + classificationNum
				+"applicant: " + applicant
				+"inventor: " + inventor
				+"applicantAdd: " + applicantAdd
				+"agency: " + agency
				+"agent: " + agent
				+"cityNum: " + cityNum
				+"legalStatus: " + legalStatus
				+ "]";
	}
	
}
